# lc1
lc1_lab <- lm_robust(lc1 ~ absenteeism, data = lab)

lc1_lab_pvals <- getParametricPValue(model = lc1_lab,
										hypothesis = "upr")

#pta
pta_lab <- lm_robust(pta ~ absenteeism, data = lab)

pta_lab_pvals <- getParametricPValue(model = pta_lab,
																		 hypothesis = "upr")


#bring_up
bring_up_lab <- lm_robust(bring_up ~ absenteeism, data = lab)

bring_up_lab_pvals <- getParametricPValue(model = bring_up_lab,
																		 hypothesis = "upr")

#assemble
assemble_lab <- lm_robust(assemble ~ absenteeism, data = lab)

assemble_lab_pvals <- getParametricPValue(model = assemble_lab,
																					hypothesis = "upr")


# absenteeism_action 
absenteeism_action_lab <- lm_robust(absenteeism_action ~ absenteeism, data = lab)

absenteeism_action_lab_pvals <- getParametricPValue(model = absenteeism_action_lab,
																					hypothesis = "upr")


#setup
control_means <- with(
	lab, 
	c(
		round(mean(lc1[absenteeism == 0],na.rm = TRUE), 2),
		round(mean(bring_up[absenteeism == 0],na.rm = TRUE), 2),
		round(mean(pta[absenteeism == 0],na.rm = TRUE), 2),
		round(mean(assemble[absenteeism == 0],na.rm = TRUE), 2),
		round(mean(absenteeism_action[absenteeism == 0],na.rm = TRUE), 2)
	)
)
control_means <- as.character(control_means)

pval_lines <- c(
	round(lc1_lab_pvals["absenteeism"],3),
	round(bring_up_lab_pvals["absenteeism"],3),
	round(pta_lab_pvals["absenteeism"],3),
	round(assemble_lab_pvals["absenteeism"],3),
	round(absenteeism_action_lab_pvals["absenteeism"],3)
)

hypothesis_lines <- c(
	"upr",
	"upr",
	"upr",
	"upr",
	"upr"
)

#make tables
sink("03_tables/ABS_attitudes_lab.tex")
print(texreg(l = list(lc1_lab,
								bring_up_lab,
								pta_lab,
								assemble_lab,
								absenteeism_action_lab),
			 omit.coef = "Intercept", include.rsquared = F,include.rmse = F,
			 table = F, use.packages = F, custom.gof.names = c("Adjusted R^2", "Observations"),
			 digits = 3, include.ci = FALSE,
			 override.pvalues = list(lc1_lab_pvals,
			 												bring_up_lab_pvals,
			 												pta_lab_pvals, 
			 												assemble_lab_pvals,
			 												absenteeism_action_lab_pvals),
			 stars = c(0.01, 0.05, 0.1),
			 custom.header = list("Involve LC1 Chair" = 1, 
			 										 "Tell village" = 2,
			 										 "Use PTA" = 3,
			 										 "Assemble group" = 4,
			 										 "Index" = 5),
			 custom.model.names =  c("(1)",
			 												"(2)",
			 												"(3)",
			 												"(4)",
			 												"(5)"),
			 custom.gof.rows = list(
			 	"Control Mean" = control_means,
			 	"$p$-values" = pval_lines,
			 	"Hypothesis" = hypothesis_lines,
			 	"Block FE" = c("No","No","No","No",
			 								 "No")),
			 reorder.gof = c(1,2,3,4,6,5)))
sink()

